<%- set_header :title=>@user.login, :description=>"#{@user.login}'s Queriac Profile - member since #{@user.created_at.strftime('%B %Y')}"-%>
<div id="primary">
	
	<% if params[:bad_command] %>
		<% keyword = params[:bad_command] %>
		<div class="msg">
		<% if current_user? %>
			<p>The command you entered (<%= keyword %>) does not exist. What do you want to do about it?</p>
			<ul class="options toolbar">
				<li class="edit"><%= link_to("Pick a default command and direct orphan queries to it.", settings_path) %></li>
				<li class="add"><%= link_to("Create a new command with keyword '#{keyword}'", new_user_command_path(:keyword => keyword)) %></li>
				<li class="search">
					<% form_tag user_command_execute_path(@user, 'search_form'), :method=>:get  do %>
						<label for="search_command">Typo? Try again:</label>
						<%= text_field_tag 'search_command', "#{params[:bad_command]} #{params[:arguments]}", :size=>30 %>
						<%= submit_tag 'Search' %>
					<% end %>
					
				</li>
			</ul>
			<% else %>
				<p>The command you entered (<%= keyword %>) does not exist.</p>
			<% end %>
		</div>
	<% elsif params[:private_command] %>	
		<div class="flash-msg warning">The <b><%= params[:private_command] %></b> command is private. You must <%= link_to("log in", new_session_path) %> to use it.</div>
	<% elsif params[:illegal_command] %>
		<div class="flash-msg warning">Sorry, <b><%= @user.login %></b> has privatized the <b><%= params[:illegal_command] %></b> command.</div>		
	<% end %>
	
	<% if @user_commands %>
		<%= render :partial => "commands/command_summary_table", :locals => {:commands => @user_commands, :title => "User Commands"} %>	
	<% else %>
		<%= render :partial => "commands/command_summary_table", :locals => {:commands => @quicksearches, :title => "Top Quicksearches"} if @quicksearches %>
		<%= render :partial => "commands/command_summary_table", :locals => {:commands => @shortcuts, :title => "Top Shortcuts"} if @shortcuts %>
		<%= render :partial => "commands/command_summary_table", :locals => {:commands => @bookmarklets, :title => "Top Bookmarklets"} if @bookmarklets %>		
	<% end %>

	
</div>

<div id="secondary">
	<h1>Search as <%= @user.login %></h1>
	<% form_tag user_command_execute_path(@user, 'search_form'), :method=>:get  do %>
		<%= text_field_tag 'search_command' %>
		<%= submit_tag 'Search' %>
	<% end %>
	<h1>Options</h1>
		<ul class="options toolbar">
			<% if current_user? %>
				<li class="add"><%= link_to "Create a new command", new_user_command_path %></li>
			<% end %>
			<li class="command"><%= link_to "View all #{whose} commands", specific_user_commands_path(@user) %></li>
			<li class="search"><%= link_to "View all #{whose} queries", user_queries_path(@user) %></li>
			<% if current_user? %>
				<li class="refresh">
					<%= link_to_function "View Commands to Update (#{@commands_to_update.size})", "$('commands_to_update_table').toggle()" %>
				</li>
			<% end %>
		</ul>
		
		<% if current_user? %>
		<div id="commands_to_update_table" style="display:none">
			<p style="font-size: 10px"><%= image_tag "icons/information.png"%> Updating your commands is optional. 
				However, the command owner or admin has probably modified the command for a good reason. You should look at the 
				new version of a command before updating.
			</p>
			<% if @commands_to_update.empty? %>
				<p>No commands to update.</p>
			<% else %>
			<%= user_command_table @commands_to_update, :columns=>[:name, :url_status], :headers=>[['User Command', {:width=>25}],['Url Status', {:width=>50}]]%>
			<% end %>
		</div>
		<% end %>
		
	<h1>Tags</h1>
	<% if ! current_user? %>
		<% cache({:section=>:tags}, :ttl=>15.minutes) do %>
			<%= tag_cloud_or_list @user.tags %>
		<% end %>
	<% else %>
		<%= tag_cloud_or_list @user.tags %>
	<% end %>
	
	<%= render :partial => "users/user_list"  %>

		
</div>